import { Link, Outlet, useLocation } from 'umi';
import styles from './index.less';
import {useEffect} from 'react'

// main.ts react 项目的主入口文件 
// 1. 全局的CSS
import '../styles/index.scss'

// 2. antd-mobile

// 3. hooks

// 4. redux
import {Provider} from 'react-redux'
import store from './../redux/store';

// 5. 淘宝适配    (1rem = 10/v width = 10vw)
import 'lib-flexible' 
import { getuserinfoasync } from '@/redux/actions';

export default function Layout() {
  const location = useLocation()

  useEffect(()=>{
    store.dispatch(getuserinfoasync())
  },[])
  useEffect(()=>{
    // console.log(location)

    // 判断 当前的路由path 上次的路由地址 
    localStorage.setItem('frompath',localStorage.getItem('topath'))
    localStorage.setItem('topath',location.pathname);
    
    // /reg    /now
    // ''      /reg 

  },[location])

  return (
    <div className={styles.all }>
      {/* context 隔空传递  */}
        <Provider store={store}>
          <Outlet />
        </Provider>
    </div>
  );
}
